package com.code2roc.jarmanage.db;

import com.code2roc.jarmanage.model.ProjectDO;
import com.code2roc.jarmanage.util.CommonUtil;
import com.code2roc.jarmanage.util.DataBaseUtil;

import java.util.ArrayList;
import java.util.List;

public class ProjectDB {

    public static void insert(ProjectDO entity) {
        entity.setProjectID(CommonUtil.getNewGuid());
        entity.setCreateDate(CommonUtil.getDateFormatToSecond());
        DataBaseUtil.insert("DepolyProject", entity);
    }

    public static void delete(String projectID) {
        DataBaseUtil.executeSQL("delete from DepolyProject where projectID='" + projectID + "'");
    }

    public static void update(ProjectDO entity) {
        DataBaseUtil.update("DepolyProject", entity, "projectID");
    }

    public static ProjectDO selectOne(String projectID) {
        return DataBaseUtil.selectOne(ProjectDO.class, "DepolyProject", "projectID", projectID);
    }

    public static List<ProjectDO> selectList(String where) {
        return DataBaseUtil.selectList(ProjectDO.class, "DepolyProject", where);
    }
}
